#!/bin/sh

#set -x

# 
# mksslkeys.sh -- generate public key and certificate for SSL communications
#

# Step 1 Setup the environment variables with the appropriate values
# NOTE: Make sure the key password will never become known to 
#       others as it allows private key retrieval from the keystore.
#       

if [ $# -ne 2 ]; then
   echo
   echo  "     Usage:  add2truststore  certificate  trustpassword"
   echo
   exit 1
fi

JAVAPATH="/opt/IBMJava2-131/jre/bin/"
x=`type -p java 2>/dev/null`
if [ "$x" != "" ]
then
  JAVAPATH=`/usr/bin/dirname $x`
fi
KEY_ALIAS=hsc_cimom
TRUSTSTORE_NAME=/opt/hsc/data/cimom.trust
CERT_FILE=$1
CERT_PASS=$2


# Step 2 Import certificate into truststore

${JAVAPATH}/keytool -import \
    -alias $KEY_ALIAS \
    -file  $CERT_FILE \
    -keystore $TRUSTSTORE_NAME \
    -storepass $CERT_PASS \
    -noprompt -v

